package com.espirit.common;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import com.espirit.eap.manager.I18n;
import com.espirit.eap.manager.workflow.WFStatus;
import com.googlecode.cswish.annotation.QLFormula;

@Entity
public class WFMessage extends Message {
	private static final long serialVersionUID = 6590823844203644447L;
	
	public static final String STATUS_OPEN = "open";
	public static final String STATUS_CLOSE = "close";


	private WFStatus status;
	@ManyToOne(targetEntity=WFStatus.class,fetch=FetchType.LAZY)
	public WFStatus getStatus() {
		return status;
	}

	public void setStatus(WFStatus status) {
		this.status = status;
	}
	

	private String statusType;
	@Transient
	public String getStatusType() {
		return statusType;
	}

	public void setStatusType(String statusType) {
		this.statusType = statusType;
	}
	
	@Transient
	@QLFormula(value = "hidden", type=Boolean.class)
	public String getStatusFlag(){
		boolean closed = this.getHidden() == null ? false : getHidden();
		if (closed){
			return new I18n("Status.Done", "Done", "已办").getName();
		} else {
			return new I18n("Status.ToDo", "ToDO", "待办").getName();
		}
	}
	
}
